package com.example.yz.happywoker;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.amap.api.maps2d.MapView;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVUser;

public class SuggestionActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_suggestion);

        ImageView suggestionActivity_back = (ImageView) findViewById(R.id.suggestionActivity_back);
        suggestionActivity_back.setOnClickListener(this);
        android.support.v7.app.ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setHomeButtonEnabled(true);
            actionBar.setDisplayHomeAsUpEnabled(true);
        }

        Button btn = (Button) findViewById(R.id.suggestion_btn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EditText suggestText = (EditText) findViewById(R.id.suggestion_content);
//                AVObject todoFolder = new AVObject("Suggestion");
//                AVUser user = AVUser.getCurrentUser();
//                todoFolder.put("userid", user.getObjectId());
//                todoFolder.put("content", suggestText.getText());
//                todoFolder.saveInBackground();
                if (suggestText.getText().length() != 0) {


                    Toast.makeText(SuggestionActivity.this, "意见反馈成功", Toast.LENGTH_LONG).show();
                    finish();
                } else {
                    Toast.makeText(SuggestionActivity.this, "内容不能为空", Toast.LENGTH_LONG).show();
                }
            }
        });
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                this.finish(); // back button
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onClick(View v) {
        finish();
    }
}

